#include <wx/richtext/richtextstyles.h>
#include "wxsrichtextstylecomboctrl.h"

namespace {
  wxsRegisterItem<wxsRichTextStyleComboCtrl> Reg( _T( "RichTextStyleComboCtrl" ), _T( "富文本样式组合控件" ), wxsTWidget, _T( "标准" ), 157 );
  WXS_ST_BEGIN( wxsRichTextStyleComboCtrlStyles, _T( "" ) )
  WXS_ST_CATEGORY( "wxRichTextStyleComboCtrl" )
  WXS_ST_DEFAULTS()
  WXS_ST_END()
}

wxsRichTextStyleComboCtrl::wxsRichTextStyleComboCtrl( wxsItemResData* Data ):
  wxsWidget(
    Data,
    &Reg.Info,
    NULL,
    wxsRichTextStyleComboCtrlStyles ),
  m_sControl( wxEmptyString ),
  m_sStyleSheet( wxEmptyString ) {}


void wxsRichTextStyleComboCtrl::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
  case wxsCPP: {
    AddHeader( _T( "<wx/richtext/richtextstyles.h>" ), GetInfo().ClassName, hfInPCH );
    Codef( _T( "%C(%W, %I, %P, %S, %T);\n" ) );
    if( !m_sControl.IsEmpty() ) {
      Codef( _T( "%ASetRichTextCtrl(%s);\n" ), m_sControl.wx_str() );
    }
    if( !m_sStyleSheet.IsEmpty() ) {
      Codef( _T( "%ASetStyleSheet(%s);\n" ), m_sStyleSheet.wx_str() );
      Codef( _T( "%AUpdateStyles();\n" ) );
    }
    BuildSetupWindowCode();
    return;
  }
  case wxsUnknownLanguage:
  default: {
    wxsCodeMarks::Unknown( _T( "wxsRichTextStyleComboCtrl::OnBuildCreatingCode" ), GetLanguage() );
  }
  }
}


wxObject* wxsRichTextStyleComboCtrl::OnBuildPreview( wxWindow* Parent, long Flags ) {
  wxRichTextStyleComboCtrl* Preview = new wxRichTextStyleComboCtrl( Parent, GetId(), Pos( Parent ), Size( Parent ), Style() );
  return SetupWindow( Preview, Flags );
}


void wxsRichTextStyleComboCtrl::OnEnumWidgetProperties( M_Code_unused long Flags ) {
  WXS_SHORT_STRING( wxsRichTextStyleComboCtrl, m_sControl, _T( "Control" ), _T( "control" ), wxEmptyString, true )
  WXS_SHORT_STRING( wxsRichTextStyleComboCtrl, m_sStyleSheet, _T( "Style Sheet" ), _T( "style_sheet" ), wxEmptyString, true )
}
